<template>
  <div>
    <el-row class="card">
      <el-col>
        <el-row class="button-margin">
          <el-button-group>
            <el-button
              plain
              size="medium"
              type="success"
              :loading="loading"
              @click="importDict"
            >
              导入
            </el-button>
            <el-button
              plain
              size="medium"
              type="warning"
              :loading="loading"
              @click="exprotDict"
            >
              导出
            </el-button>
          </el-button-group>
        </el-row>
        <el-table
          :data="tableData"
          style="width: 100%; margin-bottom: 20px"
          row-key="id"
          border
          v-loading="loading"
          lazy
          max-height="600"
          :load="loadDictItem"
          default-expand-all
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
        >
          <el-table-column label="名称" width="230" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.name }}</span>
            </template>
          </el-table-column>

          <el-table-column label="编码" width="220">
            <template slot-scope="{ row }">
              {{ row.dictCode }}
            </template>
          </el-table-column>
          <el-table-column label="值" width="230" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.value }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.createTime }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { findDictItem } from "@/api/dict";
export default {
  name: "dictList",
  components: {},
  props: {},
  data() {
    return {
      basePid: 1,
      loading: false,
      tableData: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      findDictItem(this.basePid).then((res) => {
        this.tableData = res.data;
        this.loading = false;
      });
    },
    loadDictItem(tree, treeNode, resolve) {
      findDictItem(tree.id).then((res) => {
        resolve(res.data);
      });
    },
    importDict() {},
    exprotDict() {
      window.location.href = "http://localhost:8202/admin/cmn/dict/exportDict";
    },
  },
  watch: {},
  computed: {},
  mounted() {},
};
</script>
<style scoped></style>
